#if !defined(AFX_WRITE3DSFILE_H_INCLUDED_)
#define AFX_WRITE3DSFILE_H_INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Write3DsFile.h : header file
//
#include <setjmp.h>
#include "Vge_3dsDataStructs.h"
#include "Vge_SceneDef.h"

/////////////////////////////////////////////////////////////////////////////
// CRead3DsFile document

namespace ccgis{

class AFX_EXT_CLASS CWrite3DsFile : public CObject
{
	DECLARE_DYNAMIC(CWrite3DsFile)
public:
	CWrite3DsFile();           // protected constructor used by dynamic creation
	virtual ~CWrite3DsFile();

// Attributes
public:
	// Each 3DS data-chunk starts with a 6 char header.
	// The first item in the header is a 2 char (short) id-number.
	// After that follows a int wich gives the size of
	// the data-chunk including the header. The size can be used
	// as an relative offset to the next chunk.

protected:
	H3dsScene *Scene;

private:
	jmp_buf EnvState;
	FILE *OutFile;
	int head;
//	BOOL bSceneFull;
// Operations
public:
	void WriteVertList(H3dsMeshObj *meshobj,int obji);
	void WriteFaceList(H3dsMeshObj *meshobj,int obji);
	void WriteMapList(H3dsMeshObj *meshobj,int obji);
	void WriteTraMatrix(H3dsMeshObj *meshobj,int obji);
	void WriteFaceMaterial(H3dsMatList *binding);
	void WriteTriMeshBlocks(H3dsMeshObj *meshobj,int obji);
	void WriteObjBlocks(int p,int obji);

//	void WriteMatChunk(int p, H3dsMat *mat) ;
	void WriteRGBFloat(H3dsRGBColor *rgb) ;
	void WriteRGBByte(H3dsRGBColor *rgb) ;
	void WriteShadingChunk(H3dsRGBColor *rgb) ;
//	void WriteTextureNameChunk(int p, H3dsTexture *texture) ;
//	void WriteTextureChunk(int p, H3dsTexture *texture) ;
	void WriteDoublesidedChunk(int *material_doublesided) ;
	void WriteMaterialBlocks(int p, int mati);

	void WriteKeyMeshInfoChunk(H3dsKeyMeshInfo  *KeymeshInfo);
	void WriteObjMeshBlocks(int p);
	void WriteKeyFrameBlocks(int p);
	void WriteMainBlocks(int objmeshsize, int keyframesize);

	BOOL HWrite3dsScene(void *ptr, int what); 
	BOOL Write3DS(LPCTSTR filename); 
	BOOL Get3dsScene(H3dsScene *m_pScene);

// Implementation
private:

	void dwrite(void *dest, int len);
	void HFree3dsScene(H3dsScene * scene);

};

}//end of namespace ccgis

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_WRITE3DSFILE_H_INCLUDED_)
